package com.burstly.lib.component.networkcomponent.burstly.html.ormma;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import com.burstly.lib.component.networkcomponent.burstly.html.ormma.util.OrmmaPlayer;
import com.burstly.lib.component.networkcomponent.burstly.html.ormma.util.OrmmaPlayerListener;
import com.burstly.lib.component.networkcomponent.burstly.html.ormma.util.OrmmaUtils;
import com.burstly.lib.util.Utils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;

public class OrmmaActionHandler extends Activity
{
  private HashMap<OrmmaView.ACTION, Object> mActionData = new HashMap();
  private RelativeLayout mLayout;

  private void doAction(Bundle paramBundle)
  {
    String str = paramBundle.getString("action");
    if (str == null)
      return;
    OrmmaView.ACTION localACTION = OrmmaView.ACTION.valueOf(str);
    switch (2.$SwitchMap$com$burstly$lib$component$networkcomponent$burstly$html$ormma$OrmmaView$ACTION[localACTION.ordinal()])
    {
    default:
      return;
    case 1:
      initPlayer(paramBundle, localACTION).playAudio();
      return;
    case 2:
    }
    initPlayer(paramBundle, localACTION).playVideo();
  }

  private void setPlayerListener(OrmmaPlayer paramOrmmaPlayer)
  {
    paramOrmmaPlayer.setListener(new OrmmaPlayerListener()
    {
      public void onComplete()
      {
        OrmmaActionHandler.this.finish();
      }

      public void onError()
      {
        OrmmaActionHandler.this.finish();
      }

      public void onPrepared()
      {
      }
    });
  }

  OrmmaPlayer initPlayer(Bundle paramBundle, OrmmaView.ACTION paramACTION)
  {
    OrmmaController.PlayerProperties localPlayerProperties = (OrmmaController.PlayerProperties)paramBundle.getParcelable("player_properties");
    OrmmaController.Dimensions localDimensions = (OrmmaController.Dimensions)paramBundle.getParcelable("expand_dimensions");
    OrmmaPlayer localOrmmaPlayer = new OrmmaPlayer(this);
    localOrmmaPlayer.setPlayData(localPlayerProperties, OrmmaUtils.getData("expand_url", paramBundle));
    int i = Utils.getFillparentValue();
    RelativeLayout.LayoutParams localLayoutParams;
    if (localDimensions == null)
    {
      localLayoutParams = new RelativeLayout.LayoutParams(i, i);
      localLayoutParams.addRule(13);
    }
    while (true)
    {
      localOrmmaPlayer.setLayoutParams(localLayoutParams);
      this.mLayout.addView(localOrmmaPlayer);
      this.mActionData.put(paramACTION, localOrmmaPlayer);
      setPlayerListener(localOrmmaPlayer);
      return localOrmmaPlayer;
      localLayoutParams = new RelativeLayout.LayoutParams(localDimensions.width, localDimensions.height);
      localLayoutParams.topMargin = localDimensions.y;
      localLayoutParams.leftMargin = localDimensions.x;
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    Bundle localBundle = getIntent().getExtras();
    this.mLayout = new RelativeLayout(this);
    int i = Utils.getFillparentValue();
    this.mLayout.setLayoutParams(new ViewGroup.LayoutParams(i, i));
    setContentView(this.mLayout);
    doAction(localBundle);
  }

  protected void onStop()
  {
    Iterator localIterator = this.mActionData.entrySet().iterator();
    while (localIterator.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      switch (2.$SwitchMap$com$burstly$lib$component$networkcomponent$burstly$html$ormma$OrmmaView$ACTION[((OrmmaView.ACTION)localEntry.getKey()).ordinal()])
      {
      default:
        break;
      case 1:
      case 2:
        ((OrmmaPlayer)localEntry.getValue()).releasePlayer();
      }
    }
    super.onStop();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.burstly.html.ormma.OrmmaActionHandler
 * JD-Core Version:    0.6.2
 */